I'm practicing my English ability lately in order to be recruited by a foreign company for my next job-hopping,if there is anything that I did't express precisely, please pardon me.
1.Make sure you have created a node.js module locally.
Check out your package.json, "name" and "version" are required
2.Create user in NPM Registry.
Use the add user command to set your Username, Password and Email with the hint.npm adduser
3.Checkout if your user account has been created, and verify your Email.
Go to https://www.npmjs.com/~[username], and verify your Email.
e.g: https://www.npmjs.com/~willbu...
4.Publish your node module of fisrt version.
Enter your module's directory, then use the publish command.npm publish
some error occured to me:
1.【problem】: You do not have permission to publish "sayhelloworld". Are you logged in as the correct user? : sayhelloworld
【how to solve】: There is a node module with the same name of your's in the NPM Registry already, you need to change your node module's name.
2.【problem】: You must verify your email before publishing a new package】
【how to solve】: You need to verify your email as the step 3 said.
3.【problem】: You must be logged in to publish packages
【how to solve】: Use command npm login
to login first.
5.If you want to republish after changing your module function, you need to change your version first.
Use the version command to change your module's version.
npm version [version level] // e.g: npm version patch
- "major": bump your version of the major version
- "minor": bump your version of the minor version
- "patch": bump your version of the patch level
Republish your node module.
npm publish
6.You can unpublish your node module before.
a.You can unpublish by version.
npm unpublish [module name]@[module version] // e.g: npm unpublish hellowWorld@v1.0.1
b. Or you can unpublish totally.
npm unpublish [module name] --froce // e.g: npm unpublish hellowWorld --force
Related:
Create a Node.js Module and Use it Locally
Install Pakages Using NPM
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。